#include "Solution.h"
#include <iostream>

int main()
{
	string s;
	Solution sol;
	while(getline(cin,s))
	{
		if(s=="")
			break;
		cout<<sol.romanToInt(s)<<endl;
	}
}